home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / Software / Freeware / Programare / highlight / highlight-W32GUI-2.2-10b-Setup.exe / {app} / src / ASFormatter.h < prev    next >
C/C++ Source or Header  |  2004-06-29  |  5KB  |  151 lines

  1. /*
  2.  * Copyright (c) 1998,1999,2000,2001,2002 Tal Davidson. All rights reserved.
  3.  *
  4.  * compiler_defines.h   (1 January 1999)
  5.  * by Tal Davidson (davidsont@bigfoot.com)
  6.  * This file is a part of "Artistic Style" - an indentater and reformatter
  7.  * of C, C++, C# and Java source files.
  8.  *
  9.  * The "Artistic Style" project, including all files needed to compile it,
  10.  * is free software; you can redistribute it and/or use it and/or modify it
  11.  * under the terms of the GNU General Public License as published 
  12.  * by the Free Software Foundation; either version 2 of the License, 
  13.  * or (at your option) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18.  *
  19.  * You should have received a copy of the GNU General Public
  20.  * License along with this program.
  21.  */
  22.  
  23.  
  24. #ifndef ASFORMATTER_H
  25. #define ASFORMATTER_H
  26.  
  27. #include "ASBeautifier.h"
  28. //#include "enums.h"
  29. #include "compiler_defines.h"
  30.  
  31. namespace astyle {
  32.  
  33.   class ASFormatter : public ASBeautifier
  34.     {
  35.     public:
  36.       ASFormatter();
  37.       virtual ~ASFormatter();
  38.       virtual void init(ASSourceIterator* iter);
  39.       virtual bool hasMoreLines() const;
  40.       virtual string nextLine();
  41.       void setBracketFormatMode(BracketMode mode);
  42.       void setBreakClosingHeaderBracketsMode(bool state);
  43.       void setOperatorPaddingMode(bool mode);
  44.       void setParenthesisPaddingMode(bool mode);
  45.       void setBreakOneLineBlocksMode(bool state);
  46.       void setSingleStatementsMode(bool state);
  47.       void setTabSpaceConversionMode(bool state);
  48.       void setBreakBlocksMode(bool state);
  49.       void setBreakClosingHeaderBlocksMode(bool state);
  50.       void setBreakElseIfsMode(bool state);
  51.  
  52.     private:
  53.       void ASformatter(ASFormatter ©); // not to be imlpemented
  54.       void operator=(ASFormatter&); // not to be implemented
  55.       void staticInit();
  56.       bool isFormattingEnabled() const;
  57.       void goForward(int i);
  58.       bool getNextChar();
  59.       char peekNextChar() const;
  60.       bool isBeforeComment() const;
  61.       void trimNewLine();
  62.       BracketType getBracketType() const;
  63.       bool isPointerOrReference() const;
  64.       bool isUrinaryMinus() const;
  65.       bool isInExponent() const;
  66.       bool isOneLineBlockReached() const;
  67.       void appendChar(char ch, bool canBreakLine = true);
  68.       void appendCurrentChar(bool canBreakLine = true);
  69.       void appendSequence(const string &sequence, bool canBreakLine = true);
  70.       void appendSpacePad();
  71.       void breakLine();
  72.       inline bool isSequenceReached(const string &sequence) const;
  73.       const string *findHeader(const vector<const string*> &headers, bool checkBoundry = true);
  74.  
  75.       static vector<const string*> headers;
  76.       static vector<const string*> nonParenHeaders;
  77.       static vector<const string*> preprocessorHeaders;
  78.       static vector<const string*> preDefinitionHeaders;
  79.       static vector<const string*> preCommandHeaders;
  80.       static vector<const string*> operators;
  81.       static vector<const string*> assignmentOperators;
  82.       static bool calledInitStatic;
  83.  
  84.       ASSourceIterator *sourceIterator;
  85.       vector<const string*> *preBracketHeaderStack;
  86.       vector<BracketType> *bracketTypeStack;
  87.       vector<int> *parenStack;
  88.       string readyFormattedLine;
  89.       string currentLine;
  90.       string formattedLine;
  91.       const string *currentHeader;
  92.       const string *previousOperator;
  93.       char currentChar;
  94.       char previousChar;
  95.       char previousNonWSChar;
  96.       char previousCommandChar;
  97.       char quoteChar;
  98.       unsigned int charNum;
  99.       BracketMode bracketFormatMode;
  100.       bool isVirgin;
  101.       bool shouldPadOperators;
  102.       bool shouldPadParenthesies;
  103.       bool shouldConvertTabs;
  104.       bool isInLineComment;
  105.       bool isInComment;
  106.       bool isInPreprocessor;
  107.       bool isInTemplate;            // true both in template definitions (e.g. template<class A>) and template usage (e.g. F<int>).
  108.       bool doesLineStartComment;
  109.       bool isInQuote;
  110.       bool isSpecialChar;
  111.       bool isNonParenHeader;
  112.       bool foundQuestionMark;
  113.       bool foundPreDefinitionHeader;
  114.       bool foundPreCommandHeader;
  115.       bool isInLineBreak;
  116.       bool isInClosingBracketLineBreak;
  117.       bool endOfCodeReached;
  118.       bool isLineReady;
  119.       bool isPreviousBracketBlockRelated;
  120.       bool isInPotentialCalculation;
  121.       //bool foundOneLineBlock;
  122.       bool shouldBreakOneLineBlocks;
  123.       bool shouldReparseCurrentChar;
  124.       bool shouldBreakOneLineStatements;
  125.       bool shouldBreakLineAfterComments;
  126.       bool shouldBreakClosingHeaderBrackets;
  127.       bool shouldBreakElseIfs;
  128.       bool passedSemicolon;
  129.       bool passedColon;
  130.       bool isImmediatelyPostComment;
  131.       bool isImmediatelyPostLineComment;
  132.       bool isImmediatelyPostEmptyBlock;
  133.  
  134.       bool shouldBreakBlocks;
  135.       bool shouldBreakClosingHeaderBlocks;
  136.       bool isPrependPostBlockEmptyLineRequested;
  137.       bool isAppendPostBlockEmptyLineRequested;
  138.  
  139.       bool prependEmptyLine;
  140.       bool foundClosingHeader;
  141.       int previousReadyFormattedLineLength;
  142.  
  143.       bool isInHeader;
  144.       bool isImmediatelyPostHeader;
  145.  
  146.     };
  147.  
  148. }
  149.  
  150. #endif
  151.